package com.lzw.mall.order.interceptor;

import com.lzw.mall.common.entity.Member;
import com.lzw.mall.common.vo.OrderSessionUtil;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Member m=OrderSessionUtil.getCurrent();
        if (m == null) {
            response.sendRedirect("/login");
            return false;
        }
        return true;
    }

}
